"""
demo of itemLoader
"""
from scrapy import Spider
from scrapy.loader import ItemLoader
from tutorial.item.demo_item import Product


class DemoOfItemLoader(Spider):
    """demo"""

    def parse(self, response):
        """
        :param self
        :param response
        """
        product_res = ItemLoader(item=Product(), response=response)
        product_res.add_xpath('name', '//div[@class="product_name"]')
        product_res.add_xpath('name', '//div[@class="product_title"]')
        product_res.add_xpath('price', '//p[@id="price"]')
        product_res.add_css('stock', 'p#stock]')
        product_res.add_value('last_updated', 'today')  # you can also use literal values
        return product_res.load_item()
